package com.lovo.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.system.dto.RolePermissionsDto;
import com.lovo.system.mapper.RolePermissionsMapper;
import com.lovo.system.service.IRolePermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RolePermissionsServiceImpl extends ServiceImpl<RolePermissionsMapper, RolePermissionsDto> implements IRolePermissionsService {

    @Autowired
    RolePermissionsMapper rolePermissionsMapper;

    @Override
    public void insertRolePermissions(RolePermissionsDto rolePermissionsDto) {
        rolePermissionsMapper.insert(rolePermissionsDto);
    }

    @Override
    public void deleteRolePermissions(int roleId, int permissionsId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("role_id",roleId);
        qw.eq("permissions_id",permissionsId);
        rolePermissionsMapper.delete(qw);
    }

    @Override
    public void deleteRolePermissionsByRole(int roleId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("role_id",roleId);
        rolePermissionsMapper.delete(qw);
    }

}
